<template>
	<view class="tixian">
		<view class="top">
			<image src='../../static/businessImg/back.png' class="topback" @click="back">
			</image>
			<view class="topname">
				提现
			</view>

			<view class="topend" @click="navigateTo('/pages/fenxiao/tixianlist')">
				提现记录
			</view>
		</view>

		<view class="tixiancenter">
			<view class="tixiancenter_title">
				申请提现
			</view>

			<view class="tixianjiane">
				提现金额
			</view>

			<view class="tixianjineinput">
				<span>￥</span> <input type="text" v-model="tixianprice" />
			</view>

			<view class="tixiancenter_line">

			</view>

			<view class="tixiancenter_last">
				<view class="tixiancenter_last_money">
					可用余额：{{info.balance}}
				</view>
				<view class="tixiancenter_last_all" @click="tixianprice = info.balance">
					全部提现
				</view>
			</view>
		</view>

		<view class="tixian_btn" @click="handleTixian">
			确认提现
		</view>
	</view>
</template>

<script>
	
	import storage from '@/utils/storage.js';
	import { saleHome, balanceWithdrawal } from '@/api/fenxiao.js'
	export default {
		data() {
			return {
				tixianprice: '',
				info: {}
			}
		},

		onLoad(option) {

		},
		
		mounted() {
			saleHome({
				id: storage.getUserInfo().storeId
			}).then(res => {
				this.info = res.data
			});
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				});
			},
			navigateTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			handleTixian() {
				console.log(this.tixianprice)
				if(this.tixianprice == ''){
					return uni.showToast({
						icon:'none',
						title:'请输入金额'
					})
				}
				uni.showLoading({
					
				})
				balanceWithdrawal({
					price: this.tixianprice,
					storeId: storage.getUserInfo().storeId
				}).then(res => {
					if(res.code == '000000'){
						uni.navigateTo({
							url:`/pages/fenxiao/tixianed?price=${this.tixianprice}`
						})
						uni.hideLoading()
					}else{
						uni.showToast({
							icon:'none',
							title:`${res.data}`
						})
					}
				})
				
				
			}
		}
	}
</script>

<style scoped>
	.tixian {
		width: 100%;
		min-height: 100vh;
		background: #FFFFFF;
	}

	.top {
		width: 100%;
		height: 188rpx;
		position: relative;
		background: #FFFFFF;
	}

	.topback {
		width: 16rpx;
		height: 29rpx;
		position: absolute;
		top: 106rpx;
		left: 32rpx;
	}

	.topname {
		width: 300rpx;
		height: 32rpx;
		text-align: center;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		font-size: 33rpx;
		color: #222222;
		line-height: 32rpx;
		position: absolute;
		top: 104rpx;
		left: 50%;
		transform: translateX(-50%);
	}

	.topend {
		width: 96rpx;
		height: 32rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		font-size: 24rpx;
		color: #686868;
		line-height: 32rpx;
		position: absolute;
		top: 104rpx;
		right: 30rpx;
	}

	.tixiancenter {
		width: 698rpx;
		/* padding: 0 25rpx; */

		border: 2rpx solid #f3f3f3;
		margin: 0 auto;
		margin-top: 40rpx;
	}

	.tixiancenter_title {
		width: 100%;
		height: 90rpx;
		line-height: 90rpx;
		padding-left: 25rpx;
		background: #f3f3f3;
		font-family: Microsoft YaHei;
		font-weight: 400;
		font-size: 30rpx;
		color: #1B1A20;
	}

	.tixianjiane {
		width: 100%;
		padding-left: 25rpx;
		margin-top: 30rpx;
		font-family: Microsoft YaHei;
		font-weight: 300;
		font-size: 24rpx;
		color: #5E5E5E;
	}

	.tixianjineinput {
		width: 100%;
		height: 38rpx;
		display: flex;
		align-items: flex-end;
		padding: 0 25rpx;
		margin-top: 31rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		font-size: 38rpx;
		color: #282828;

		input {
			height: 38rpx !important;
		}
	}

	.tixiancenter_line {
		width: 100%;
		height: 2rpx;
		background: #f3f3f3;
		margin-top: 27rpx;
	}

	.tixiancenter_last {
		width: 100%;
		margin-top: 20rpx;
		height: 24rpx;
		line-height: 24rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 30rpx;
		padding: 0 25rpx;
	}

	.tixiancenter_last_money {
		width: 70%;
		font-family: Microsoft YaHei;
		font-weight: 300;
		font-size: 24rpx;
		color: #5E5E5E;
	}

	.tixiancenter_last_all {
		flex: 1;
		font-family: Microsoft YaHei;
		font-weight: 400;
		font-size: 24rpx;
		color: #FF4D49;
		text-align: right;
	}

	.tixian_btn {
		width: 698rpx;
		height: 94rpx;
		line-height: 94rpx;
		text-align: center;
		background: rgb(255, 77, 73);
		font-family: Microsoft YaHei;
		font-weight: 400;
		font-size: 36rpx;
		color: #FFFFFF;
		margin: 0 auto;
		margin-top: 45rpx;
		border-radius: 15rpx;
	}
</style>
